<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
	    <title></title>
	    <meta charset="utf-8">
	    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	    <link rel="stylesheet" href="skin/base.css">
	    <link rel="stylesheet" href="skin/news.css">
	    <script src="js/zy_control.js"></script>
	    <script src="js/zy_click.js"></script>
		<script src="js/zy_slide.js"></script>
		<script src="js/config.js"></script>
		<script src="js/common.js"></script>
	</head>
	<body>
		<div id="main">
        </div>
	</body>
	<script>
	zy_init();
	
	var page=1;
	function GetUrl(t){
		if (t == -1) {
			$$('main').className="loading";
		}
		if(t<1){
			page=1;
		}
		
		var url = OpenAPI.news_list+'/?client_id='+OpenAPI.client_id+'&dataType=json&catalog=3&page='+(t<1?1:page);
		uexXmlHttpMgr.open(t,'post',url,"8000");
		uexXmlHttpMgr.send(t);
		//logs(url);
	}

	window.uexOnload=function(type){
		if(!type){
			uexWindow.setBounce("1");
			uexWindow.setBounceParams("0",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
	　　　　	uexWindow.setBounceParams("1",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"","pullToReloadText":"上拉加载更多","releaseToReloadText":"释放加载","loadingText":"加载中，请稍等"}');
	　　　　	uexWindow.showBounceView("0","#f3f3f3","1");
	　　　　	uexWindow.notifyBounceEvent("0","1");
			uexWindow.showBounceView("1","#f3f3f3","1");
　　　　		uexWindow.notifyBounceEvent("1","1");
			uexWindow.onBounceStateChange=function(t,s){
	　　　　　　	if(t=="0"||t=="1"){//下方弹动时
	　　　　　　　　	if(s=="2"){//松开手指时
						GetUrl(t);						
					}
	　　　　　　	}
	　　　　	}
	
			uexXmlHttpMgr.onData = function(opId, status, data){
				uexXmlHttpMgr.close(opId);
				uexWindow.resetBounceView(opId);
				if(status==1){
					if(opId<1){
						uexWindow.setBounceParams("0",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"上次更新：'+Now()+'","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
						$$("main").className='';
						$$('main').innerHTML = '<ul id="newslist" class="news" ></ul>';
					}
					
					data=JSON.parse(data);
					var List=data['newslist'];
					if(List.length>0){
					    for(k in List){
							var li=document.createElement("li");
							if( !List[k]['object'] ) List[k]['object']='';
							if( !List[k]['url'] ) List[k]['url']='';
							li.setAttribute("onclick", "javascript:jump("+List[k]['id']+","+List[k]['type']+",'"+List[k]['object']+"','"+List[k]['url']+"');");
							li.setAttribute("ontouchstart", "javascript:zy_touch('down');");

							var html ='';
							html +='<div class="t">';
							html +='<div class="lb">'+
							       '<h3>'+List[k]['title']+'</h3>'+
								   //'<p>'+List[k]['description']+'</p>'+
								   '</div>';
			
							//html +='<div class="rb loadimg"><img src="'+List[k]['thumb']+'" class="hide" onload="this.className=\'\'" /></div>';
							html +='</div>';
							
							html +='<span><em class="l">'+List[k]['author']+' 发布于 '+List[k]['pubDate']+' ('+List[k]['commentCount']+'评)</em></span>';
							
							li.innerHTML = html;
							$$('newslist').appendChild(li);
						}
						
						page++;
					}else{
						if(opId==-1)
						{
							$$("main").className='notdata';
						}				
					}
					
				}else if(status==-1){
					if(opId==-1){
						$$("main").className='errer';
					}else{
						uexWindow.toast("0","5",'加载失败',1000);
					}
				}
			}
			GetUrl(-1);
		}
	}

	function jump(id,type,object,url){
		switch (type) {	//[0-链接新闻|1-软件推荐|2-讨论区帖子|3-博客|4-普通新闻|7-翻译文章]
		    case 0:
		        loadLink(url);
		        break;
		    case 2:
				localStorage['post_id'] = object;
				uexWindow.open('post_detail','0','post_detail.html','2','', '',0x0);
		        break;
		    case 3:
				localStorage['blog_id'] = object;
				uexWindow.open('blog_detail','0','blog_detail.html','2','', '',0x0);
		        break;
		    default:
				localStorage['news_id'] = id;
		        uexWindow.open('news_detail','0','news_detail.html','2','', '',0x0);
		        break;
		}
		
	}
	</script>
</html>